//创建路由  并抛出

//创建路由
import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'

//引入页面
import Home from '@/view/Home.vue'
import My from '@/view/My.vue'
import List from '@/view/List.vue'
import Detail from '@/view/Detail.vue'
import Part2 from '@/view/Part2.vue'


// hash(#) history(后端服务进行配置)


const router = createRouter({
    history: createWebHistory(),
    // 路由
    routes: [
        {
            path: '/',
            redirect: "/home",

        },

        {
            path: '/home',
            component: Home,

        },
        {
            path: '/my',
            component: My,
            name:"wode"

        },
        {
            path: '/list',
            //重定向
            // redirect:{name:'pp2'},
            redirect:'/list/part3',
            component: List,
            children: [
          
                
                {
                    // query示例
                    path: 'part1',
                    // path:'',
                    component: () => import('@/view/Part1.vue')
                },
                { 
                    //params示例
                    path: 'part2/:id/:name/:hobby',
                    component: () => import('@/view/Part2.vue'),
                    // component:Part2,
                    name:'pp2',
                    props:true,
                    //默认传参
                    // props:{
                    //     id:0,
                    //     name:"花子",
                    //     hobby:"跳房子"
                    // }
                },

                { 
                    path: 'part3',
                    // path:'',
                    component: () => import('@/view/Part3.vue')},

                { 
                    path: 'part4',
                    component: () => import('@/view/Part4.vue')},
            ],

        },
        {
            path: '/detail',
            component: Detail,

        }
    ]
})

export default router